<?php

/**
 * O2O团购PC版本
 * ============================================================================
 * * 版权所有 2009-2016 郑州司科计算机科技有限公司，并保留所有权利。
 * 购买网址: http://www.jzphp.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
  * 咨询电话：400-823-0371 QQ：313999875
 * ============================================================================
 * $Author: zzsike $
 * $Time 2016-02-03 sammy $
*/


require_once(dirname(dirname(dirname(__FILE__))) . '/app.php');

need_manager();
need_auth('team');

$now = time();
$condition = array(
	'system' => 'Y',
	"end_time > {$now}",
	'business_audit' => array('C','T'),
);
$conditions = array(
	'system' => 'Y',
	'city_id'=>$login_user[city_id],
	"end_time > {$now}",
	'business_audit' => array('C','T'),
);

/* filter start */
$team_type = strval($_GET['team_type']);
if ($team_type) { $condition['team_type'] = $team_type; }
$team_id = abs(intval($_GET['team_id']));
if ($team_id) {
	$condition['id'] = $team_id;
} else { $team_id = null; }
$team_key = strval($_GET['team_key']);
if ($team_key ) {
	$condition[] = "title LIKE '%".mysql_escape_string($team_key)."%'";
}
/* filter end */
/*代理商 filter start */
$team_type = strval($_GET['team_type']);
if ($team_type) { $conditions['team_type'] = $team_type; }
$team_id = abs(intval($_GET['team_id']));
if ($team_id) {
	$conditions['id'] = $team_id;
} else { $team_id = null; }
$team_key = strval($_GET['team_key']);
if ($team_key ) {
	$conditions[] = "title LIKE '%".mysql_escape_string($team_key)."%'";
}
/* filter end */

$count = Table::Count('team', $condition);
list($pagesize, $offset, $pagestring) = pagestring($count, 20);

$teams = DB::LimitQuery('team', array(
	'condition' => $condition,
	'order' => 'ORDER BY id DESC',
	'size' => $pagesize,
	'offset' => $offset,
));
$teamss = DB::LimitQuery('team', array(
	'condition' => $conditions,
	'order' => 'ORDER BY id DESC',
	'size' => $pagesize,
	'offset' => $offset,
));
$cities = Table::Fetch('category', Utility::GetColumn($teams, 'city_id'));
$groups = Table::Fetch('category', Utility::GetColumn($teams, 'group_id'));

$citiess = Table::Fetch('category', Utility::GetColumn($teamss, 'city_id'));
$groupss = Table::Fetch('category', Utility::GetColumn($teamss, 'group_id'));

$selector = 'index';
include template('manage_team_index');
